"""visualization"""
import numpy as np
import matplotlib.pyplot as plt


def show_pointcloud_cls(data, label=None, save=None):
    data = data.astype(np.float32)
    plt.figure(figsize=(8, 6))
    ax = plt.subplot(111, projection='3d')
    ax.view_init(elev=30, azim=-60)
    plt.axis('off')
    ax.scatter(data[:, 0], data[:, 1], data[:, 2], s=8, marker='.')
    ax.text(0, 0, 0, label)

    if save:
        plt.savefig(save, dpi=500, bbox_inches='tight', transparent=True)
        plt.close()
    else:
        plt.show()


def show_pointcloud_seg(data, seg=None, save=None):
    data = data.astype(np.float32)
    plt.figure(figsize=(8, 6))
    ax = plt.subplot(111, projection='3d')
    ax.view_init(elev=30, azim=-60)
    plt.axis('off')
    ax.scatter(data[:, 0], data[:, 1], data[:, 2], c=seg, s=8, marker='.')

    if save:
        plt.savefig(save, dpi=500, bbox_inches='tight', transparent=True)
        plt.close()
    else:
        plt.show()

